{extend name="$_tpl_public_layout_danceadmin"/}


{block name="breadcrumb"}
<ol class="breadcrumb">
	<li class="breadcrumb-item"><a href="{:url('admin/index/index')}">{:config('system.site_title')}</a></li>
	<li class="breadcrumb-item"><a href="{:url('admin/systemRule/index')}">{$sideName}</a></li>
</ol>
{/block}


{block name="pageheader"}
{$sideName}
{/block}


{block name="content"}
<div class="card mb-3">
	<div class="card-header">
		添加/编辑
	</div>
	<div class="card-body">
		<form action="{:url('admin/systemRule/doAdd')}" method="post" class="form-horizontal J_ajaxForm">
			<input type="hidden" name="id" value="{$id}" />
			<div class="form-group row">
				<label class="col-md-2 control-label">菜单名称</label>
				<div class="col-md-5">
					<input type="text" class="form-control" name="data[name]" value="{$info['name']}" />
				</div>
				<div class="col-md-5 help-block">用于后台显示的配置标题</div>
			</div>
			<div class="form-group row">
				<label class="col-md-2 control-label">菜单分类</label>
				<div class="col-md-5 J_cate">
					<?php echo selectHtmlB($cateList, 'data[cid]', $info['cid'], 'name', 'id', 'form-control'); ?>
				</div>
				<div class="col-md-5"></div>
			</div>
			<div class="form-group row">
				<label class="col-md-2 control-label">上级菜单</label>
				<div class="col-md-5 J_parent">
					<?php echo selectHtmlB($parentTree, 'data[parentid]', $info['parentid'], 'title_show', 'id', 'form-control'); ?>
				</div>
				<div class="col-md-5"></div>
			</div>
			<div class="form-group row">
				<label class="col-md-2 control-label">module</label>
				<div class="col-md-5">
					<input type="text" class="form-control" name="data[module]" value="{$info['module']}" />
				</div>
				<div class="col-md-5"></div>
			</div>
			<div class="form-group row">
				<label class="col-md-2 control-label">controller</label>
				<div class="col-md-5">
					<input type="text" class="form-control" name="data[controller]" value="{$info['controller']}" />
				</div>
				<div class="col-md-5"></div>
			</div>
			<div class="form-group row">
				<label class="col-md-2 control-label">action</label>
				<div class="col-md-5">
					<input type="text" class="form-control" name="data[action]" value="{$info['action']}" />
				</div>
				<div class="col-md-5"></div>
			</div>
			<div class="form-group row">
				<label class="col-md-2 control-label">参数</label>
				<div class="col-md-5">
					<input type="text" class="form-control" name="data[parameter]" value="{$info['parameter']}" />
				</div>
				<div class="col-md-5"></div>
			</div>
			<div class="form-group row">
				<label class="col-md-2 control-label">附属菜单控制器</label>
				<div class="col-md-5">
					<textarea class="form-control" name="data[subsidiary]" rows="3">{$info['subsidiary']}</textarea>
				</div>
				<div class="col-md-5"></div>
			</div>
			<div class="form-group row">
				<label class="col-md-2 control-label">按钮样式</label>
				<div class="col-md-5">
					<input type="text" class="form-control" name="data[btn_class]" value="{$info['btn_class']}" />
				</div>
				<div class="col-md-5 help-block">可填入的样式：btn-primary,btn-info,btn-success,btn-warning,btn-danger,btn-inverse,btn-pink,btn-purple,btn-yellow,btn-grey,btn-light,btn-link,btn-vk,btn-twitter,btn-tumblr</div>
			</div>
			<div class="form-group row">
				<label class="col-md-2 control-label">排序</label>
				<div class="col-md-5">
					<input type="number" class="form-control" name="data[vieworder]" value="{$info['vieworder']}" value="99" />
				</div>
				<div class="col-md-5 help-block">按照数值大小的倒序进行排序，数值越大越靠前</div>
			</div>
			<div class="form-group row">
				<label class="col-md-2 control-label">状态</label>
				<div class="col-md-5">
					<?php echo isOpenRadioHtmlB('data[state]', $info['state']); ?>
				</div>
				<div class="col-md-5"></div>
			</div>
			<div class="form-group row">
				<label class="col-md-2 control-label">是否显示</label>
				<div class="col-md-5">
					<?php echo isOpenRadioHtmlB('data[display]', $info['display'], 1); ?>
				</div>
				<div class="col-md-5"></div>
			</div>
			<div class="form-group row">
				<label class="col-md-2 control-label">是否独立权限</label>
				<div class="col-md-5">
					<?php echo isOpenRadioHtmlB('data[is_selfauth]', $info['is_selfauth'], 1); ?>
				</div>
				<div class="col-md-5"></div>
			</div>
			<div class="form-group row">
				<label class="col-md-2 control-label">是否独立菜单</label>
				<div class="col-md-5">
					<?php echo isOpenRadioHtmlB('data[is_selfmenu]', $info['is_selfmenu'], 1); ?>
				</div>
				<div class="col-md-5"></div>
			</div>
			<div class="clearfix form-actions">
				<div class="offset-md-2 col-sm-10">
					<button type="submit" class="btn btn-primary btn-sm J_ajaxSubmit">确定</button>
				</div>
			</div>
		</form>
	</div>
</div>
{/block}


{block name="script"}
<script type="text/javascript">
var url = "{:url('admin/systemRule/getParentByCid')}";
$('.J_cate').on('change', 'select', function(e){
	e.preventDefault();
	var cid = $(this).val();
	var param = {
		cid: cid
	};
	$.get(url, param, function(ret){
		if(ret.code == 1){
			var data = ret.data;
			var list = data.parentTree;
			if(list){
				var html = '<option value="0">请选择</option>';;
				for (o in list){
					html += '<option value='+list[o].id+'>'+list[o].title_show+'</option>';
				}
				html += '';
				$('.J_parent>select').html(html);
				$('.J_parent>select').show();
			}else{
				$('.J_parent>select').html('<option value="0"></option>');
				$('.J_parent>select').hide();
			}
		}else if(ret.code == 0){
			Wei.Util.wapTipNew({msg: ret.msg, icon: 2, time: ret.time});
		}
	},'json');
});
</script>
{/block}